package com.holly.unit.deform.starter;

import com.holly.unit.deform.*;
import com.holly.unit.deform.api.*;
import com.holly.unit.deform.config.DeformConfig;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 类描述: 表单设计器自动配置
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/4/8 15:04
 */
@Configuration
public class DeformAutoConfiguration {

    /**
     * 接口规范
     *
     * @author holly
     * @date 2020/12/1 14:40
     */
    @Bean
    @ConditionalOnMissingBean(DeformBaseInfoApi.class)
    public DeformBaseInfoApi deformBaseInfoApi() {
        return new DeformBaseInfoOperator();
    }

    @Bean
    @ConditionalOnMissingBean(DeformDataApi.class)
    public DeformDataApi deformDataApi() {
        return new DeformDataOperator();
    }

    @Bean
    @ConditionalOnMissingBean(DeformAuthApi.class)
    public DeformAuthApi deformAuthApi() {
        return new DeformAuthOperator();
    }

    @Bean
    @ConditionalOnMissingBean(DeformFacadeApi.class)
    public DeformFacadeApi deformFacadeApi() {
        return new DeformFacadeOperator();
    }

    @Bean
    @ConditionalOnMissingBean(DeformTempletApi.class)
    public DeformTempletApi deformTempletApi() {
        return new DeformTempletOperator();
    }

    @Bean
    @ConditionalOnMissingBean(DeformUrlAuthApi.class)
    public DeformUrlAuthApi deformUrlAuthApi() {
        return new DeformUrlAuthOperator();
    }

    @Bean
    @ConditionalOnMissingBean(DeformRouterApi.class)
    public DeformRouterApi deformRouterApi() {
        return new DeformRouteOperator();
    }

    @Bean
    @ConfigurationProperties(prefix = "holly.desform")
    public DeformConfig deformConfig() {
        return new DeformConfig();
    }

    @Bean
    @ConditionalOnMissingBean(DeformEngineApi.class)
    public DeformEngineApi deformEngineApi() {
        return new DeformEngineOperator(deformConfig());
    }

    @Bean
    @ConditionalOnMissingBean(DeformExtLinkApi.class)
    public DeformExtLinkApi deformExtLinkApi() {
        return new DeformExtLinkOperator(deformConfig());
    }

    @Bean
    @ConditionalOnMissingBean(DeformComponentApi.class)
    public DeformComponentApi deformComponentApi(){
        return new DeformComponentOperator();
    }

    @Bean
    @ConditionalOnMissingBean(DeformOnlineApi.class)
    public DeformOnlineApi deformOnlineApi(){
        return new DesignFormOnlineOperator();
    }


}
